package com.dmw.demo.dto;

import cn.hutool.json.JSONUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Response {

    private boolean success; // 状态码（-1-失败 0-空 1 成功）
    private Object data;
    private String msg;

    public static String ok() {
        Response response = new Response(true, null, null);
        return JSONUtil.toJsonStr(response);
    }

    public static String ok(Object data) {
        Response response = new Response(true, data, null);
        return JSONUtil.toJsonStr(response);
    }

    public static String Empty() {
        Response response = new Response(false, null, "没有查询到数据！");
        return JSONUtil.toJsonStr(response);
    }

    public static String fail() {
        Response response = new Response(false, null, null);
        return JSONUtil.toJsonStr(response);
    }

    public static String fail(String msg) {
        Response response = new Response(false, null, msg);
        return JSONUtil.toJsonStr(response);
    }
}
